package cn.jiyun.controller;

import cn.jiyun.pojo.Foods;
import cn.jiyun.service.FoodsService;
import cn.jiyun.vo.ResultCommon;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("foods")
@CrossOrigin
public class FoodsController {

    @Autowired
    private FoodsService foodsService;

    @RequestMapping("findAll")
    public ResultCommon findAll(@RequestBody Foods foods){
        List<Foods> foodsList = foodsService.findAll(foods);
        return ResultCommon.suceessData(foodsList);
    }

    @RequestMapping("add")
    public void add(@RequestBody Foods foods){
        foods.setBiaoqian("低糖,低盐");
        foodsService.add(foods);
    }
    @RequestMapping("update")
    public void  update(@RequestBody Foods foods){
        foodsService.update(foods);
    }
    @RequestMapping("delete")
    public void delete(Integer id){
        foodsService.delete(id);
    }


}
